/*
 * @Author: silence
 * @Date: 2022-01-14 16:16:22
 * @LastEditTime: 2022-05-03 08:43:47
 * @LastEditors: silence_szn 8475963+silence-szn@user.noreply.gitee.com
 * @Description: logger
 * @FilePath: /flutter_template_app/lib/utils/log/MyLog.dart
 */

import 'package:logger/logger.dart';
import 'package:mybase/base/tool/empty/FFEmpty.dart';

class Mylog {
  static Logger _myLogger = Logger(
      printer: PrefixPrinter(
          PrettyPrinter(methodCount: 0, printTime: false, colors: false)));

  static void v(dynamic message) {
    _myLogger.v(message);
  }

  static void d(dynamic message) {
    _myLogger.d(message);
  }

  static void i(dynamic message) {
    _myLogger.i(message);
  }

  static void w(dynamic message) {
    _myLogger.w(message);
  }

  static void e(dynamic message) {
    _myLogger.e(message);
  }

  static void wtf(dynamic message) {
    _myLogger.wtf(message);
  }

  /**
   * @description: 打印请求的信息
   * @param url 接口地址，param 参数，result 结果
   * @return void
   */
  static void p({String url = '', dynamic param, dynamic result,dynamic header,dynamic responseHeader,String? apiTime}) {
    Map<String, dynamic> map = {};

    if (url.isNotEmpty) {
      map['url'] = url;
    }

    if (!FFEmpty.stringIsEmpty(apiTime)) {
      map['apiTime'] = apiTime;
    }

    if (header != null) {
      map['header'] = header;
    }

    if (param != null) {
      map['param'] = param;
    }

    if (responseHeader != null) {
      map['responseHeader'] = responseHeader;
    }

    if (result != null) {
      map['result'] = result;
    }

    _myLogger.v(map);
  }
}
